<link rel="stylesheet" href="../core/resource/weui/weui.css?v=19">
<style type="text/css">
body{background:#eee}
.storelogo img{width:3.2rem;height:3.2rem}
.merchgroup .store-star {padding:0.1rem 0 0.2rem 0;font-size:0.55rem;line-height:1rem}
.merchgroup .store-star img{height:0.66rem}
.star-on,.star-off{position:absolute;top:1rem;left:0;overflow:hidden}
.star-rate {margin-left:3.6rem}
.store-distance{float:right;color:#999}
.store-moneylimit{font-size:0.55rem}
</style>
<div class="fui-page order-create-page fui-page-current">
	 <div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">确认订单</div>
		<div class="fui-header-right"></div>
	</div>
	<div class="fui-content">
		<div class="weui_cells">
            <div class="weui_cell">
                <div class="weui_cell_hd"><img style="width:2rem;height:2rem;margin-right:5px;display:block" ng-src="{{tomedia(pagedata.goods.image) || '../core/resource/images/nopic.jpg'}}"/></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <span style="float:left">{{pagedata.goods.title}}</span>
					
                </div>
                <span style="float:left;font-size:1rem;color:red">单价：￥{{pagedata.goods.price}}</span>
            </div>
			
			<div class="weui_cell weui_cell_select weui_select_after">
					<div class="weui_cell_hd">
						购买数量({{pagedata.goods.unit}})
					</div>
					<div class="weui_cell_bd weui_cell_primary">
					   <input class="weui_input" onkeyup="this.value=this.value.replace(/\D/g,'')"  pattern="[0-9]*" ng-change="num();add();"  placeholder="请输入购买数量" ng-model="pagedata.post.num">
					</div>
			</div>
        </div>
		
		<div class="weui_cells">
		<div class="weui_cell weui_cell_select weui_select_after" >
                <div class="weui_cell_hd"><label class="weui_label">添加备注</label></div>
                <div class="weui_cell_bd weui_cell_primary">
                    <input ng-model="pagedata.post.remark" class="weui_input" type="text" placeholder="添加备注">					
                </div>
        </div>
		
		<div class="weui_cell weui_cell_select weui_select_after">
					<div class="weui_cell_hd">
						配送地址：
					</div>
					<div class="weui_cell_bd weui_cell_primary">
					  <input ng-model="pagedata.post.address.address" class="weui_input" type="text" placeholder="">			
					</div>
		</div>
		<div class="weui_cell weui_cell_select weui_select_after">
					<div class="weui_cell_hd">
						联系人：
					</div>
					<div class="weui_cell_bd weui_cell_primary">
					  <input ng-model="pagedata.post.address.name" class="weui_input" type="text" placeholder="">			
					</div>
		</div>
		<div class="weui_cell weui_cell_select weui_select_after">
					<div class="weui_cell_hd">
						电话：
					</div>
					<div class="weui_cell_bd weui_cell_primary">
					  <input ng-model="pagedata.post.address.mobile" class="weui_input" type="text" placeholder="">			
					</div>
		</div>
		</div>
		<div class="weui_cells_title">
			<p style="color:#19b955"><i class="icon jinyunicon icon-information"></i>订单金额包含运费</p>
		</div>
		
		<div class="weui_cells_title">
			<p style="color:#19b955"><i class="icon jinyunicon icon-information"></i>地址使用默认地址</p>
		</div>
		<div ng-if="pagedata.goods.minbuy>0" class="weui_cells_title">
			<p style="color:#19b955"><i class="icon jinyunicon icon-information"></i>最低购买数量{{pagedata.goods.minbuy}}</p>
		</div>
		
</div>
<div class="fui-footer quick">
	<div class="quick-info">
		<span class="price" id="cart-price" style="line-height:2.0rem">￥{{pagedata.post.allprice}}.00</span>
	</div>
	<div class="quick-submit" id="btn-submit" href="javascript:" ng-click="pagedata.gopay()" style="margin: 0">确认下单</div>
</div>
</div>
<script type="text/javascript">
 window.scope.pagedata.post.id= window.scope.pagedata.goods.id;
var num=0;
scope.num = function(){
 num =window.scope.pagedata.post.num;

}
scope.add = function(){
var fee= window.scope.pagedata.goods.price * num;
 window.scope.pagedata.post.allprice=fee;

}

</script>
<script>

scope.pagedata.gopay=function(){
		if(scope.pagedata.post.num<0 || scope.pagedata.post.num==undefined){
			alert('请先填写数量');
			return;
		}
		if(scope.pagedata.mixbuy>scope.pagedata.post.num){
			alert('最少购买'+scope.pagedata.mixbuy +'件');
			return;
		}
	var params={
		data:scope.pagedata.post,
		op:'get',
		callback:function(res){
			if(res.payid){
				require(['tool'],function(tool){
					tool.pay(res.payid,function(res){
						if(res.type=='success'){
							scope.message('支付成功！','','jy_supplier/order/');
							
						}else{
							scope.message('支付失败！失败原因：'+res.message,'error');
						}
					});
				});
			}
		}
	};
	scope.post_json(params);
	return

}
</script>